<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <meta http-equiv="X-UA-Compatible" content="ie=edge" />
    <title>单行文字垂直居中</title>
    <style>
      div {
        width: 200px;
        height: 40px;
        background-color: pink;

        line-height: 40px;
      }
    </style>
  </head>

  <body>
    <div>我要居中</div>
  </body>
</html>
